<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>发表评论</title>
	<link rel="stylesheet" href="js/filedisk.css" type="text/css">
	<style type="text/css">
		.c1 {
			width: 100px;
			height: 100px;
			border: 3px solid #F3970C;
			border-radius: 50%;
			overflow: hidden;
		}

		label {
			position: relative;
		}

		#userimg {
			position: absolute;
			left: 1px;
			top: 0px;
			opacity: 0;
			width: 100px;
			height: 24px;
		}

		#userbtn {
			font-size: 16px;
			padding: 1px 1px;
			background: none;
			color: #0055ff;
			border: none;
			width: 100px;
		}

		.text-container {
			/* 只能显示一行文字的样式*/
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}

		.thin-table {
			border-collapse: collapse;
			/* 折叠边框 */
			width: 80%;
		}

		.thin-table {
			border-left: 1px solid #c3d0da;
			/* table的左边框 */
			border-right: 1px solid #c3d0da;
			/* table的右边框 */
			border-top: 1px solid #c3d0da;
			/* table的顶部边框 */
			border-bottom: 1px solid #c3d0da;
			/* table的底部边框 */
		}

		.thin-table th,
		.thin-table td {
			padding: 12px;
			/* 单元格内边距 */
			text-align: left;
			/* 单元格内文本对齐方式 */
			vertical-align: top;
			/* 单元格内文本垂直对齐方式 */
			border-top: 1px solid #c3d0da;
			/* 仅显示下边框线 */
			border-bottom: 1px solid #c3d0da;
			/* 仅显示下边框线 */
		}

		.STYLE2 {
			color: #FF0000
		}
	</style>
</head>

<body>
	<table width="100%" height="100%" border="0" cellpadding="1" cellspacing="0" class="TitleColor">
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<!--
		<tr>
			<td>&nbsp;</td>
			<td height="30px"><a href="forum.htm">首页 </a> » <a href="javascript:history.back();"> 返回 </a> » 发表评论</td>	
			<td>&nbsp;</td>	
		</tr>
		-->
		<tr>
			<td>&nbsp;</td><!--左边空白间隙部分-->

			<td width="60%" height="100%" valign="top">
				<table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0"><!--中间显示部分-->
					<tr>
						<td width="100%" height="100%">
							<table width="100%" height="100%" border="0" bgcolor="#FFFFFF">
								<tr>
									<td>&nbsp;</td>
									<td width="95%" valign="top" height="100%">
										<table width="100%" border="0" cellpadding="1" cellspacing="0"><!--中间显示部分-->
											<tr>
												<td height="40px"><a href="forum.htm">首页 </a> » <a
														href="javascript:history.back();"> 返回 </a> » 发表评论</td>
											</tr>

											<tr>
												<td height="40px">内容</td>
											</tr>
											<tr>
												<td> <textarea
														style="min-height:500px; min-width:100%; max-height:80%; max-width:400px;"
														placeholder="输入内容" id="posttext" maxlength=''></textarea></td>
											</tr>
											<!--
								<tr>
									<td>&nbsp;</td>
								</tr>
								-->
											<tr>
												<td>
													<table width="100%" border="0">
														<tr>
															<td>
																<label for="userimg">
																	<input type="button" id="userbtn" value="插入图片"
																		align="middle">
																	<input type="file" id="userimg"
																		onChange="selectImg(this);" accept="image/*"
																		title="选择图片">
																</label>
															</td>
															<td>&nbsp;</td>
															<td>&nbsp;</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>&nbsp;</td>
											</tr>
											<tr>
												<td align="left"><input type="submit" onClick="confirm()" value="提交评论"
														style="height:40px;width:100px;"></td>
											</tr>
											<tr>
												<td>&nbsp;</td>
											</tr>
											<tr>
												<td><span class="STYLE2">温馨提示: 帖子需审核后才会显示哦，后台会在发贴后8小时内审核。请耐心等待!</span>
												</td>
											</tr>
										</table>
									</td><!--中间显示部分-->

									<td>&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td><!--中间显示部分-->


			<td>&nbsp;</td><!--右边空白间隙部分-->
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td height="50" align="center">
				<div id='footerpage'></div>
			</td>
			<td>&nbsp;</td>
		</tr>
	</table>

</body>
<!--
<script src="js/blueimp-md5-2.18.0.js"></script>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/spark-md5.min.js"></script>
<script src="js/base64.js"></script>
-->
<script>
	function loadScript(c, d) { var b = document.createElement("script"); b.type = "text/javascript"; var e = sessionStorage.getItem(c); e ? (b.textContent = e, d(b)) : fetch(c).then(function (a) { return a.text() }).then(function (a) { b.textContent = a; sessionStorage.setItem(c, a); d(b); location.reload() })["catch"](function (a) { console.error("Error loading the script:", a) }) };
	loadScript("tu_0.js", function (script) { document.head.appendChild(script); });
</script>
<script type="text/javascript" language="javascript">
	if (sessionStorage.getItem("tu_0.js")) {		// 读取记忆是否已保存js文件
		loadHtml("footer.htm", "footerpage");
	}

	/*
	$('#userimg').change(function() {
		var fileInput = document.getElementById('userimg');
		if(!fileInput.files || !fileInput.files[0]){
			alert("无效文件");
			return;
		}
		var file = fileInput.files[0];
		// 获取textarea元素
		var text = document.getElementById('posttext');
		// 添加字节
		//var name += file.name;
		text.value += "\n"+file.name+"\n"; //'添加的字节内容'; 
	})
	*/

	//var isReply = sessionStorage.getItem("isReply");
	var CommentId = sessionStorage.getItem("CommentId");
	var ForumId = sessionStorage.getItem("ForumId");
	var PostId = sessionStorage.getItem("PostId");
	var WorksType = sessionStorage.getItem("WorksType");



	var first = 0;
	function fun() {
		if (first == 0) {
			first = 1;
			setTimeout(function () { myTimer("cookie", 0, 0) }, 0);		//自动发送post指,只有打开页面的时候，才发送一次	
		} else {

		}
	}
	setInterval("fun()", 1000);			// 周期性调用函数 每隔100毫秒调用一次


	function confirm() {
		var posttext = document.getElementById("posttext").value;
		if (posttext == "") {
			alert('内容不能为空');
			return false;
		}
		myTimer("replyopr", 0, 0);
	}
	function myTimer(type, file, value) {
		var phpName;
		if (type == "read" || type == "replyopr") {
			phpName = "forum.php";
		} else {
			phpName = "index.php";
		}
		var xhr = postPhp(phpName);

		xhr.onreadystatechange = function () {			//2.注册回调函数
			var array_name = txtUnzip(xhr);
			if (array_name != null) {
				if (type == "cookie") {
					cookiemyFunction(array_name)	// 返回的信息在html页面显
				}
				if (type == "read") {
					myFunction(array_name)			// 返回的信息在html页面显
				}
				if (type == "replyopr") {
					replyoprmyFunction(array_name)	// 返回的信息在html页面显
				}
			}
		}

		if (type == "cookie") {
			txtZip(xhr, "t:ncki");
		}
		if (type == "replyopr") {
			var operate = 0; // 0增1删2改
			var replyText = txtB64Enc(document.getElementById("posttext").value);	// 内容
			alert("operate--" + operate + "--PostId--" + PostId + "--WorksType--" + WorksType + "--ForumId--" + ForumId + "--CommentId--" + CommentId);
			txtZip(xhr, "t:sfro&fidr:" + ForumId + "&fbwt:" + WorksType + "&fpid:" + PostId + "&fcid:" + CommentId + "&frdt:" + replyText + "&fopr:" + operate, 1);
			/*
			if(isReply == 1){		// 回复评论
				txtZip(xhr, "t:sfro&fidr:" + ForumId + "&fbwt:" + WorksType + "&fpid:" + PostId + "&fcid:" + CommentId + "&frdt:" + replyText + "&fopr:" + operate);
			}else{					// 发表评论
				txtZip(xhr, "t:sfco&fidr:" + ForumId + "&fbwt:" + WorksType + "&fpid:" + PostId + "&fcdt:" + commentText + "&fopr:" + operate); 
			}
			*/
		}
	}

	function cookiemyFunction(arr) {
		switch (arr.result) {
		case "ok":
			console.log('cookiemyFunction ok');
		//myTimer("read",0,0);
			break;
		default:
			alert('请先登录后，再操作！');
			window.location.href = "user.htm";
			return false;
		}
	}

	function replyoprmyFunction(arr) {
		switch (arr.result) {
		case "ok":
			console.log('replyoprmyFunction ok');
			javascript: history.back();
			break;
		default:
			alert('回复失败，请重新回复！');
			return false;
		}
	}

</script>

</html>